<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	template="/WEB-INF/templates/template.xhtml"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	>
	<ui:define name="content">
		<ui:include src="/includes/menu.xhtml"></ui:include>
		
	<a4j:outputPanel id="eventpanel" layout="block">
    	<rich:panel style="float:left; width:800px; padding:5px;">
		<h1><h:outputText value="Událost" /></h1>		
		<h:form>	
			<h2>
				<h:outputText value="#{eventBean.description}" rendered="#{not eventBean.admin}"/>
				<h:inputText value="#{eventBean.description}" rendered="#{eventBean.admin}"/>
			</h2>
			
			<h:panelGrid columns="2">
				<h:outputText value="Datum konání: "/>
				<h:outputText value="#{eventBean.eventDate}" rendered="#{not eventBean.admin}"/>
				<h:inputText value="#{eventBean.eventDate}" rendered="#{eventBean.admin}"/>
				<h:outputText value="Založil: "/>
				<h:outputText value="#{eventBean.event.webuser.nick}"/>
			</h:panelGrid>
			
			<h3><h:outputText value="O události: "/></h3>
			<h:outputText value="#{eventBean.text}" rendered="#{not eventBean.admin}"/>
			<h:inputTextarea value="#{eventBean.text}" rendered="#{eventBean.admin}"/>
			
			<h:panelGrid columns="1">
				<a4j:commandButton value="Uložit změny" action="#{eventBean.saveChanges()}" rendered="#{eventBean.admin}"/>
			</h:panelGrid>
		</h:form>  
		
		<h2><h:outputText value="Attendants" /></h2>
		<a4j:outputPanel id="out" ajaxRerendered="true">
			<rich:dataTable id="tabl"  value="#{eventBean.attendants}" var="attendant">
				<rich:column>
					<f:facet name="header">
						<h:outputText value="id" />
					</f:facet>			
					<h:outputText value="#{attendant.id}" />
				</rich:column>	
				<rich:column>
					<f:facet name="header">
						<h:outputText value="name" />
					</f:facet>	
					<h:outputText value="#{attendant.name}" />
				</rich:column>	
				<rich:column>
					<f:facet name="header">
						<h:outputText value="contact" />
					</f:facet>	
					<h:outputText value="#{attendant.contact}" />
				</rich:column>	
				<rich:column rendered="#{eventBean.admin}">
					<f:facet name="header">
						<h:outputText value="delete" />
					</f:facet>
					<h:form>
						<a4j:commandButton value="delete" action="#{eventBean.deleteAttendant(attendant.id)}" />
					</h:form>
				</rich:column>		
			</rich:dataTable>
		</a4j:outputPanel>
		
		<h:link value="Přihlásit se" outcome="create-attendant" includeViewParams="true">
			<f:param name="event" value="#{eventBean.eventID}"/>
		</h:link>
		</rich:panel>
		</a4j:outputPanel>
	</ui:define>
</ui:composition>